home *** CD-ROM | disk | FTP | other *** search
- Path: news.tiac.net!usenet
- From: edickau@highground.com (Ellen L. Dickau)
- Newsgroups: comp.lang.c++
- Subject: VC++ 4.1 virtual destructors and wrong delete oper
- Date: 20 Apr 1996 00:05:57 GMT
- Organization: HighGround Systems, Inc.
- Message-ID: <4l99p5$88s@news.tiac.net>
- NNTP-Posting-Host: 205.161.49.141
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
-
- I have version 4.1 of MS Visual C++ and I am seeing the following problem
- which is documented as fixed in MS Visual C++ 4.0. The problem has to do with
- virtual destructors in a class that is exported from a DLL (when you call
- delete on the class the wrong delete operator is called if the class has a
- virtual destructor). Can anyone confirm that this problem has reappeared in
- 4.1?
-
- The workaround described in the article makes the problem go away, but I'd
- still like acknowledgement that the problem is there and I am trying this
- newsgroup until the microsoft news groups become available.
-
- thanks,
- -Ellen Dickau
-
- Here is the initial part of the Microsoft documentation of the problem:
-
- PSS ID Number: Q122675
- Article last modified on 01-19-1996
-
- 7.00 | 1.00 1.50 1.51 1.52 | 1.00 2.00 2.10 2.20
-
- MS-DOS | WINDOWS | WINDOWS NT
-
-
- ----------------------------------------------------------------------
- The information in this article applies to:
-
- - The Microsoft C/C++ compiler (CL.EXE), included with:
-
- - Microsoft C/C++ for MS-DOS, version 7.0
- - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52
- - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 2.1,
- and 2.2
- ----------------------------------------------------------------------
-
- SYMPTOMS
- ========
-
- When allocating and deleting an object of a class that is exported from a
- DLL, you may find that the new operator in the EXE is called to allocate
- the memory but the delete operator in the DLL is called to delete the
- memory. Therefore, there is a new/delete mismatching problem, which may
- cause run-time errors.
-
- CAUSE
- =====
-
- This problem is a result of the way objects are allocated, constructed,
- destructed and deallocated. The following things occur when allocating
- and deallocating objects that have constructors and destructors:
-
- Allocating:
-
- A1. The memory that the object will reside in is allocated.
- A2. The appropriate constructor for that object is called.
-
- Deallocating:
-
- D1. The destructor for the object is called.
- D2. If the object is being deallocated via delete, call delete.
-
- Step D2 is where the problem arises for objects created from classes
- exported from a DLL. Steps D1 and D2 are often carried out by a scalar or
- vector deleting destructor, which is a helper function generated at compile
- time. When this helper function is created in the DLL, any calls it makes
- to the delete operator will be in the context of the DLL. Therefore the
- delete operator overridden in the EXE will not be called as expected.....
-
-
-
- ....
-
-